using CodePlex.TfsLibrary;
using CodePlex.TfsLibrary.Utility;

namespace CodePlex.CodePlexClientLibrary
{
    public class ApplyPatchPresenter
    {
        readonly IFileSystem fileSystem;
        readonly IPatchEngine patchEngine;
        readonly IApplyPatchView view;

        public ApplyPatchPresenter(IPatchEngine patchEngine,
                                   IFileSystem fileSystem,
                                   IApplyPatchView view)
        {
            this.patchEngine = patchEngine;
            this.fileSystem = fileSystem;
            this.view = view;
        }

        public void ApplyPatch(string directory,
                               string patchFilename)
        {
            patchEngine.ApplyPatch(directory, fileSystem.ReadAllText(patchFilename), view.ShowStatus);
        }
    }
}